package com.powergisol.gis.service.impl;

import com.powergisol.gis.dao.BoreholeQueryMapper;
import com.powergisol.gis.dao.ReciverDao;
import com.powergisol.gis.entity.TabArea;
import com.powergisol.gis.entity.TabZuankong;
import com.powergisol.gis.service.BoreholeQueryService;
import com.powergisol.gis.service.SaveDataService;
import com.powergisol.gis.util.CamelNamedUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SaveDataServiceImpl implements SaveDataService {


    @Autowired
    private ReciverDao reciverDao;

    @Autowired
    BoreholeQueryMapper boreholeQueryMapper;

    @Autowired
    BoreholeQueryService boreholeQueryService;



    @Override
    public void saveBatch(List tbsData) {
        //以事务方式批量提交数据cnyImport1
        tbsData.forEach(data->{
            reciverDao.autoSave(data);
//            String tableName = CamelNamedUtil.camel2Underline(data.getClass().getSimpleName());
//            if("tab_zuankong".equals(tableName)){
//                TabZuankong tabZuankong = (TabZuankong)data;
//                String point = "POINT("+tabZuankong.getZKX()+" "+tabZuankong.getZKY()+")";
//                TabArea tabArea = boreholeQueryMapper.getAreaByPoint(point);
//                if(null != tabArea){
//                    boreholeQueryMapper.upZk(tabArea.getCode(),num+"");
//                }
//            }
        });
//        boreholeQueryService.upZkCode();

    }

    @Override
    public void saveBatchTf(List tbsData) {
        //以事务方式批量提交数据
        tbsData.forEach(data->{
            reciverDao.autoSaveTf(data);
        });

    }


}
